﻿using System.IO;
using UnityEditor.Android;
using UnityEngine;
namespace QQSDK
{
    public class AndroidPostBuild : IPostGenerateGradleAndroidProject
    {
        private static SDKData data; //所有数据
        public int callbackOrder
        {
            get
            {
                return 999;
            }
        }

        void IPostGenerateGradleAndroidProject.OnPostGenerateGradleAndroidProject(string path)
        {
            data = JsonMapper.ToObject<SDKData>(File.ReadAllText(Application.dataPath + "/QQSDK/Ads/Res/" + "sdkConfig.json"));
            string gradlePropertiesFile = path + "/gradle.properties";

            if (File.Exists(gradlePropertiesFile))
            {
                File.Delete(gradlePropertiesFile);
            }
            StreamWriter writer = File.CreateText(gradlePropertiesFile);
            writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
            writer.WriteLine("android.useAndroidX=true");
            writer.WriteLine("android.enableJetifier=true");
            writer.WriteLine("android.enableR8=false");
            writer.Flush();
            writer.Close();
        }
    }

}